package com.example.xcService.pojo.channels;

import lombok.Data;

import java.io.Serializable;

@Data
public class ChannelResult<T> implements Serializable {
    public  Integer code;
    public  String errorMsg;

    public  T data;

    public  String bizOrderCode;

    private  boolean success;

    public ChannelResult(int code) {
        this.code = code;
    }

    public ChannelResult(int code, String message) {
        this.code = code;
        this.errorMsg = message;
    }

    public ChannelResult() {

    }

    public ChannelResult(int code, String message, Boolean success) {
        this.code = code;
        this.errorMsg = message;
        this.success = success;
    }

    public ChannelResult(int code, String message, Boolean success,T data) {
        this.code = code;
        this.errorMsg = message;
        this.success = success;
        this.data = data;
    }

    public ChannelResult(int code, String message, Boolean success,String bizOrderCode) {
        this.code = code;
        this.errorMsg = message;
        this.success = success;
        this.bizOrderCode = bizOrderCode;
    }

    public ChannelResult(int code, String message, Boolean success,String bizOrderCode,T data) {
        this.code = code;
        this.errorMsg = message;
        this.success = success;
        this.bizOrderCode = bizOrderCode;
        this.data=data;
    }


    public ChannelResult(int code, String message, T data) {
        this.code = code;
        this.errorMsg = message;
        this.data = data;
    }
    public static <T> ChannelResult<T> IN_PROCESS() {
        return new ChannelResult<>(ResultEnum.IN_PROCESS, "充值中",true);
    }

    public static <T> ChannelResult<T> FAILED() {
        return new ChannelResult<>(ResultEnum.FAILED, "充值失败",true);
    }

    public static <T> ChannelResult<T> IN_PROCESS(String msg) {
        return new ChannelResult<>(ResultEnum.IN_PROCESS, msg,true);
    }

    public static <T> ChannelResult<T> FAILED(String msg) {
        return new ChannelResult<>(ResultEnum.FAILED, msg,true);
    }

    public static <T> ChannelResult<T> success(String msg) {
        return new ChannelResult<>(ResultEnum.SUCCESS, msg,true);
    }

    public static <T> ChannelResult<T> success(String msg,String bizOrderCode) {
        return new ChannelResult<>(ResultEnum.SUCCESS, msg,true,bizOrderCode);
    }

    public static <T> ChannelResult<T> success(String msg,String bizOrderCode,T data) {
        return new ChannelResult<>(ResultEnum.SUCCESS, msg,true,bizOrderCode,data);
    }

    public static <T> ChannelResult<T> success(T data) {
        return new ChannelResult(ResultEnum.SUCCESS, null, true,data);
    }

    public static <T> ChannelResult<T> success(T data, String msg) {
        return new ChannelResult<>(ResultEnum.SUCCESS, msg,true, data);
    }

    public static <T> ChannelResult<T> error(String msg) {
        return new ChannelResult<>(ResultEnum.ERROR, msg,false);
    }
    public static <T> ChannelResult<T> error(int code,String msg) {
        return new ChannelResult<>(code, msg,false);
    }
    public static <T> ChannelResult<T> error(String msg, T data) {
        return new ChannelResult<>(ResultEnum.ERROR, msg,false, data);
    }

    public static <T> ChannelResult<T> error(String msg, int code) {
        return new ChannelResult<>( code,msg,false);
    }
}
